//
//  HNSH_GroupChatInfoCommonCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/17.
//

#import "HNSH_GroupChatInfoCommonCell.h"

@interface HNSH_GroupChatInfoCommonCell ()
/** */
@property (nonatomic, strong)UILabel * titleLabel;
/** */
@property (nonatomic, strong)UILabel * desLabel;
/** */
@property (nonatomic, strong)UIImageView * rightImgView;
/** */
@property (nonatomic, strong)UIImageView * rightDesImgView;
/** */
@property (nonatomic, strong)UIView * segView;
@end

@implementation HNSH_GroupChatInfoCommonCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = [UIColor appWhiteLabelColor];
        [self addAllViews];
        [self addAllLayout];
    }
    return self;
}

//MARK: Myself Methods
- (void)addAllViews{
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.desLabel];
    [self.contentView addSubview:self.rightImgView];
    [self.contentView addSubview:self.rightDesImgView];
    [self.contentView addSubview:self.segView];
}

- (void)addAllLayout{
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.height.mas_equalTo(self.contentView);
    }];
    [self.rightImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.width.mas_equalTo(16);
        make.height.mas_equalTo(16);
        make.centerY.mas_equalTo(self.contentView);
    }];
    [self.rightDesImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.rightImgView.mas_left).offset(-6);
        make.width.mas_equalTo(16);
        make.height.mas_equalTo(16);
        make.centerY.mas_equalTo(self.contentView);
    }];
    [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.rightImgView.mas_left).offset(-6);
        make.top.height.mas_equalTo(self.contentView);
    }];
    [self.segView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(-0);
        make.height.mas_equalTo(0.5);
        make.bottom.mas_equalTo(0);
    }];
}

//MARK: Setter Methods
- (void)setDic:(NSDictionary *)dic{
    _dic = dic;
    
    self.titleLabel.text = dic[@"title"];
    self.desLabel.text = dic[@"des"];
    
    self.rightDesImgView.hidden = YES;
    self.desLabel.hidden = NO;
    if ([self.titleLabel.text isEqualToString:@"群二维码"]) {
        self.rightDesImgView.image = [UIImage imageNamed:@"chat_qun_setup_qrcode"];
        self.rightDesImgView.hidden = NO;
    } else if ([self.titleLabel.text isEqualToString:@"群头像"]) {
        [self.rightDesImgView sd_setImageWithURL:[NSURL URLWithString:self.desLabel.text] placeholderImage:[UIImage imageNamed:@"chat_icon_myqun"]];
        self.rightDesImgView.hidden = NO;
        self.desLabel.hidden = YES;
    }
}

//MARK: Getter Methods
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.textColor = [UIColor appBlackLabelColor];
    }
    return _titleLabel;
}

- (UILabel *)desLabel{
    if (!_desLabel) {
        _desLabel = [UILabel new];
        _desLabel.font = [UIFont systemFontOfSize:16];
        _desLabel.textColor = [UIColor appBlackLabelColor];
        _desLabel.textAlignment = NSTextAlignmentRight;
        _desLabel.numberOfLines = 0;
    }
    return _desLabel;
}

- (UIImageView *)rightImgView{
    if (!_rightImgView) {
        _rightImgView = [UIImageView new];
        _rightImgView.image = [UIImage imageNamed:@"base_nav_show_right"];
    }
    return _rightImgView;
}

- (UIImageView *)rightDesImgView{
    if (!_rightDesImgView) {
        _rightDesImgView = [UIImageView new];
        _rightDesImgView.hidden = YES;
    }
    return _rightDesImgView;
}

- (UIView *)segView{
    if (!_segView) {
        _segView = [UIView new];
        _segView.backgroundColor = [UIColor colorWithHexString:@"#F2F3F6"];
    }
    return _segView;
}
@end
